package 题目集.dfs;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 思路：
 *  1.把每一个关系放入map集合中，
 *  深度遍历该map集合，确定自身的版本。
 *  https://pintia.cn/problem-sets/1734588112958099456/exam/problems/1734588149226246155?type=7&page=0  
 */
public class 功夫传人 {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] read = null;
        read = in.readLine().split(" ");
        int n = Integer.parseInt(read[0]);
        double strength = Double.parseDouble(read[1]);
        double decay = (100 - Double.parseDouble(read[2])) / 100;
        Map<Integer,Integer> map=new HashMap<>();
        double[] child = new double[n];
        List<Integer> list=new ArrayList<>();   //待求的得道者
        for (int i = 0; i < n; i++) {
            read = in.readLine().split(" ");
            int k = Integer.parseInt(read[0]);
            if (k == 0) {
                list.add(i);
                child[i]= Double.parseDouble(read[1]);
                continue;
            }
            for (int j = 1; j <= k; j++) {
                int m = Integer.parseInt(read[j]);
                map.put(m,i);
            }
        }
        double sum=0;
        int[] dp=new int[n];
        for (Integer i : list) {
            int version = getVersion(map, i,dp);
            sum+=strength*Math.pow(decay,version-1)*child[i];
        }
        System.out.println((int)sum);
    }
    public static int getVersion(Map<Integer,Integer> map,Integer curr,int[] dp){
        if (curr==null){
            return 0;
        }
        if (dp[curr]!=0){
            return dp[curr];
        }
        int version = getVersion(map, map.get(curr), dp)+1;
        dp[curr]=version;
        return dp[curr];
    }
}

